package com.lx.pc.service.information.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.stereotype.Service;

import com.lx.pc.domain.entity.information.InformationEntity;
import com.lx.pc.domain.vo.information.InformationVo;
import com.lx.pc.mybatis.repository.information.InformationRepository;
import com.lx.pc.service.AbstractService;
import com.lx.pc.service.information.IInformationService;
import com.lx.pc.utils.OmsPage;


@Service("informationService")
public class InformationServiceImpl extends AbstractService<InformationEntity, InformationVo, BigInteger, InformationRepository> implements IInformationService{

	@Override
	public int findByInformationCount(InformationVo information) {

		return repository.findByInformationCount(information);
	}

	@Override
	public OmsPage<InformationVo> findByInformation(InformationVo information, Integer page, Integer size) {
		OmsPage<InformationVo> pages = new OmsPage<InformationVo>();
		pages.setTotal(repository.findByInformationCount(information));
		List<InformationEntity> list = repository.findByInformation(information,page = (page - 1) * size,size);
		pages.setResult(etoV(list));
		return pages;
	}

	@Override
	public InformationVo findByInformationId(BigInteger id) {

		return etoV(repository.findByInformationId(id));
	}

}
